import java.util.ArrayList;

public class Tset8 {
    public static void main(String[] args) {
        ArrayList<Phone> list = new ArrayList<>();
        Phone p1 = new Phone("小米",1000);
        Phone p2 = new Phone("苹果",8000);
        Phone p3 = new Phone("华为",2000);
        list.add(p1);
        list.add(p2);
        list.add(p3);
        ArrayList<Phone> phones = getPhone(list);
        for (int i = 0; i < phones.size(); i++) {
            Phone phone = phones.get(i);
            System.out.println(phone.getBrand()+", "+phone.getPrice());
        }

    }
    /*我要干嘛
    1.需要什么
    2.方法调用处是否需要使用结果
    3.要返回多个数据,放到一个容器中,再把容器返回
     */
    public static ArrayList<Phone> getPhone(ArrayList<Phone> list){
        //定义一个集合返回符合条件的
        ArrayList<Phone> ret = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            Phone p = list.get(i);
            int price = p.getPrice();
            if(price<3000){
                ret.add(p);
            }
        }
        return ret;
    }
}
